﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using DAL.Data;

namespace DAL.Classes.Repository
{
    public class EmployeeRepository: Repository
    {
        public Employee GetEmployeeByLoginAndPassword(string login, string password)
        {
            var emp = DataBase.Employees.FirstOrDefault(x => x.Login == login && x.Password == password);
            return emp;
        }

        public Role GetRoleByName(RoleTypes roleType)
        {
            var role = DataBase.Roles.FirstOrDefault(x => x.Id == (int)roleType);
            return role;
        }

        public void CreateEmployee(Employee emp)
        {
            DataBase.AddToEmployees(emp);
        }

        public Employee Get(Expression<Func<Employee, Boolean>> filter)
        {
            var emp = DataBase.Employees.FirstOrDefault(filter);
            return emp;
        }
    }
}
